﻿using System;
using System.IO;
using WeatherAnywhere;
using WeatherAnywhere.Wmr200;
using Xunit;

namespace WeatherAnywhereTest
{
    public class SensorReportTest
    {
        [Fact]
        public void Should_decode_data()
        {
            using (var reader = new BinaryReader(GetType().Assembly.GetManifestResourceStream("WeatherAnywhereTest.temperature_1_67_72.bin")))
            {
                var bytes = reader.ReadBytes(256);

                ISensorReport sensorReport = new SensorReport(bytes);
                Assert.Equal(1, sensorReport.Id);
                Assert.Equal(new DateTime(2013, 11, 24, 22, 36, 0), sensorReport.Date);
                Assert.Equal(6.7, sensorReport.Temperature);
                Assert.Equal(2, sensorReport.DewPoint);
                Assert.Equal(72, sensorReport.Humidity);
                Assert.Equal(HeatIndex.NotAvailable, sensorReport.HeatIndex);
                Assert.Equal("Id 1, 24/11/2013 22:36:00 : T 6,7°C / H 72% / DP 2°C / HI NotAvailable", sensorReport.ToString());
            }
        }
    }
}